﻿<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>通讯录表单</title>
    <link href="/Themes/Styles/style.css" rel="stylesheet" />
    <script src="../../Themes/Scripts/jquery-1.8.2.min.js"></script>
    <script src="/Themes/Scripts/DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/Validator/JValidator.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/artDialog/artDialog.source.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/artDialog/iframeTools.source.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/FunctionJS.js" type="text/javascript"></script>
    <script>
        $(function () {
            divresize('.ScrollBar', 90);
            InitBindDrop();
            if (IsNullOrEmpty(GetQuery('key'))) {
                InitControl();
                SubCompanyClick("SubCompanyId");
                InitControl();
                CompanyClick("CompanyId");
                InitControl();
                DepartmentClick("DepartmentId");
                InitControl();
            }
        })
        //初始化绑定下拉框，公司，部门，工作组,数据字典
        var datajson = "";
        function InitBindDrop() {
            //集团、公司，部门，工作组
            $("#SubCompanyId").append("<option value=''>" + "==请选择==" + "</option>");
            $("#CompanyId").append("<option value=''>" + "==请选择==" + "</option>");
            $("#DepartmentId").append("<option value=''>" + "==请选择==" + "</option>");
            $("#WorkgroupId").append("<option value=''>" + "==请选择==" + "</option>");
            getAjax("/Organize/LoadAction", "action=LoadBindDrop", function (data) {
                datajson = eval("(" + data + ")");
                $.each(datajson, function (i) {
                    if (datajson[i].Category == '集团') {
                        $("#SubCompanyId").append($("<option></option>").val(datajson[i].OrganizationId).html(datajson[i].FullName));
                    }
                });
            })
        }
        function SubCompanyClick(id) {
            $("#CompanyId").empty();
            $("#CompanyId").append("<option value=''>" + "==请选择==" + "</option>");
            $.each(datajson, function (i) {
                if (datajson[i].ParentId == $('#' + id).val()) {
                    $("#CompanyId").append("<option value='" + datajson[i].OrganizationId + "'>" + datajson[i].FullName + "</option>");
                }
            });
        }

        function CompanyClick(id) {
            $("#DepartmentId").empty();
            $("#DepartmentId").append("<option value=''>" + "==请选择==" + "</option>");
            $.each(datajson, function (i) {
                if (datajson[i].ParentId == $('#' + id).val()) {
                    $("#DepartmentId").append("<option value='" + datajson[i].OrganizationId + "'>" + datajson[i].FullName + "</option>");
                }
            });
        }
        function DepartmentClick(id) {
            $("#WorkgroupId").empty();
            $("#WorkgroupId").append("<option value=''>" + "==请选择==" + "</option>");
            $.each(datajson, function (i) {
                if (datajson[i].ParentId == $('#' + id).val()) {
                    $("#WorkgroupId").append("<option value='" + datajson[i].OrganizationId + "'>" + datajson[i].FullName + "</option>");
                }
            });
        }
        //保存事件
        function AcceptClick() {
            if (!CheckDataValid('#form1')) {
                return false;
            }
            var postData = GetWebControls("#form1");
            getAjax("/Tel/AcceptClick?key=" + GetQuery('key'), postData, function (data) {
                if (IsNullOrEmpty(GetQuery('key'))) {
                    if (data) { AlertParmCallback("恭喜您，更新成功。"); return false; }
                } else {
                    if (data) { AlertParmCallback("恭喜您，新增成功。"); return false; }
                }
                if (!data) {
                    Alert_Error("很抱歉，操作失败。"); return false;
                } else {
                    Alert_Wern(data); return false;
                }
            });
        }
        //得到一个对象实体
        function InitControl() {
            getAjax("/Tel/InitControl", { key: GetQuery('key') }, function (data) {
                var data = eval("(" + data + ")");
                SetWebControls(data);
            });
        }
    </script>
</head>
<body>        
    <form id="form1">
        <input id="hiddenSubCompanyId" type="hidden" />
        <input id="hiddenCompanyId" type="hidden" />
        <input id="hiddenDepartmentId" type="hidden" />
        <input id="hiddenWorkgroupId" type="hidden" />
        <div class="bd">
            <div class="tipstitle_title settingtable bold bd todayInfoPanelTab rightPanelTitle_normal">
                <div class="tab_list_top" style="position: absolute">
                    <div id="basicTab" class="tab_list bd actived" onclick="Tabchange('tb_basic')">基本信息</div>
                </div>
            </div>
            <div class="ScrollBar">
                <br />
                <div id="tb_basic" class="tabPanel">
                    <table border="0" cellpadding="0" cellspacing="0" class="frm">
                        <tr>
                            <th>姓名[<font face="宋体">*</font>]：</th>
                            <td>
                                <input id="RealName" maxlength="50" type="text" datacol="yes" err="姓名" checkexpession="NotNull" class="txt" style="width: 220px" />
                            </td>
                            <th>性别：</th>
                            <td>
                                <select id="Sex" class="select" style="width: 226px">
                                    <option value="男">男</option>
                                    <option value="女">女</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th>地点[<font face="宋体">*</font>]：</th>
                            <td>
                                <input id="Location" maxlength="50" type="text" datacol="yes" err="地点" class="txt" style="width: 220px" />
                            </td>
                            <th>集团[<font face="宋体">*</font>]：
                            </th>
                            <td>
                                <select id="SubCompanyId" onchange="SubCompanyClick(this.id)" class="select" datacol="yes" err="集团" checkexpession="NotNull" style="width: 227px">
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th>公司[<font face="宋体">*</font>]：
                            </th>
                            <td>
                                <select id="CompanyId" onchange="CompanyClick(this.id)" class="select" datacol="yes" err="公司" checkexpession="NotNull" style="width: 227px">
                                </select>
                            </td>
                            <th>部门名称<font face="宋体"></font>：
                            </th>
                            <td>
                                <select id="DepartmentId" onchange="DepartmentClick(this.id)" class="select" datacol="yes" checkexpession="NotNull" err="部门名称" style="width: 227px">
                                </select>
                            </td>
                        </tr>

                        <tr>
                            <th>工作组名称：
                            </th>
                            <td>
                                <select id="WorkgroupId" class="select" style="width: 227px">
                                </select>
                            </td>
                            <th>电话1[<font face="宋体">*</font>]：</th>
                            <td>
                                <input id="Tel1" maxlength="50" type="text" datacol="yes" err="电话1" checkexpession="NotNull" class="txt" style="width: 220px" />
                            </td>
                        </tr>

                        <tr>

                            <th>电话2<font face="宋体"></font>：</th>
                            <td>
                                <input id="Tel2" maxlength="50" type="text" datacol="yes" err="电话2" class="txt" style="width: 220px" />
                            </td>
                            <th>电话3<font face="宋体"></font>：</th>
                            <td>
                                <input id="Tel3" maxlength="50" type="text" datacol="yes" err="电话3" class="txt" style="width: 220px" />
                            </td>
                        </tr>
                        <tr>
                            <th>有效：</th>
                            <td>
                                <span class="item">
                                    <input id="Enabled" type="checkbox" checked="checked" style="vertical-align: middle;" />
                                    <label for="Enabled" style="vertical-align: middle;">有效</label>
                                    &nbsp;&nbsp;
                                </span>
                            </td>
                        </tr>

                        <tr>
                            <th>描述：</th>
                            <td colspan="3">
                                <textarea id="Description" maxlength="200" type="text" class="txtArea" rows="5" style="width: 594px"></textarea>
                            </td>
                        </tr>
                    </table>
                </div>

                <div class="frmbottom">
                    <a id="Accept" class="l-btn" href="javascript:void(0)" onclick="AcceptClick();"><span class="l-btn-left">
                        <img src="/Themes/Images/16/accept.png" alt="" />确 认</span></a>

                    <a class="l-btn" href="javascript:void(0)" onclick="OpenClose();"><span class="l-btn-left">
                        <img src="/Themes/Images/16/cancel.png" alt="" />关 闭</span></a>
                </div>
    </form>
</body>
</html>
